<?php
if(!isset($dbselect)) //前面没设置 数据库 则指定使用 DB3
    $dbselect   = Db::G3();
///关于标收费信息的统计
$sfwhere      = "";
if($startdate!="" && $enddate!=""){
    $_stime     = strtotime($startdate);
    $_etime     = strtotime($enddate);
    $sfwhere    = " and sf.repay_yestime>='$_stime' and  sf.repay_yestime<='$_etime'";  
} 
$rows = $dbselect->GetRows("SELECT b.cid,sf.repay_yesdate '收费时间',sf.t_type as '收费类型',SUM(sf.money) AS '收费金额', COUNT(sf.money) AS '次数'
FROM 05b_2list_sf as sf left join 05b_0base  as b on sf.bid=b.bid
WHERE sf.is_repay>0 $sfwhere
GROUP BY cid, sf.repay_yesdate,t_type ");
foreach($rows as &$row)
{   
    $cid    = $row['cid'];
    $ctime  = strtotime($row['收费时间']);
    $Y      = date("Y", $ctime);
    $M      = date("n", $ctime);
    $D      = date("j", $ctime); 
    $count  = $row['次数'];
    CTLog::G()->doctAndDayReal($count.",rp_{$Y}{$m}_st01",1,'tot_b_ss_'.$row['收费类型'],$row['收费金额'],$Y,$M,$D);// 统计当日实际收到的收费 [t_typ 是收费名目 比如 glf，fxj]
    CTLog::G()->doctAndDayReal($count.",rp_{$Y}{$m}_cid",$cid,"tot_b_ss_".$row['收费类型'],$row['收费金额'],$Y,$M,$D);
}



$rows = $dbselect->GetRows("SELECT b.cid,SUBSTR( sf.time_h, 1, 10 ) '添加时间',sf.t_type as '收费类型',SUM(sf.money) AS '收费金额', COUNT(sf.money) AS '次数'
FROM 05b_2list_sf as sf left join 05b_0base  as b on sf.bid=b.bid
WHERE sf.is_repay>0 $sfwhere
GROUP BY cid,SUBSTR( sf.time_h, 1, 10 ),t_type ");
foreach($rows as &$row)
{   
    $cid    = $row['cid'];
    $ctime  = strtotime($row['添加时间']);
    $Y      = date("Y", $ctime);
    $M      = date("n", $ctime);
    $D      = date("j", $ctime); 
    $count  = $row['次数'];
    CTLog::G()->doctAndDayReal($count.",rp_{$Y}{$m}_st01",1,'tot_b_ys_'.$row['收费类型'],$row['收费金额'],$Y,$M,$D);// 统计当日实际收到的收费 [t_typ 是收费名目 比如 glf，fxj]
    CTLog::G()->doctAndDayReal($count.",rp_{$Y}{$m}_cid",$cid,"tot_b_ys_".$row['收费类型'],$row['收费金额'],$Y,$M,$D);
}
